package team.sun.sss.controller.staff;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import team.sun.sss.dao.staff.*;
import team.sun.sss.pojo.staff.*;
import team.sun.sss.service.staff.StaffServiceImpl;
import team.sun.sss.service.user.UserServiceImpl;

@Controller
public class StaffUpdateController {

    @Autowired
    StaffServiceImpl staffService;
    @Autowired
    UserServiceImpl userService;
    @Autowired
    StaffCertificateDao staffCertificateDao;
    @Autowired
    StaffCourseDao staffCourseDao;
    @Autowired
    StaffRewardDao staffRewardDao;
    @Autowired
    StaffTrainDao staffTrainDao;
    @Autowired
    StaffTakeStudentDao staffTakeStudentDao;
    @Autowired
    StaffThesisDao staffThesisDao;
    @Autowired
    StaffDao staffDao;


    //带学生情况编辑
    @PostMapping("/take_student_update")
    public String takeStudentUpdate(@ModelAttribute(value = "staffTakeStudent") StaffTakeStudent staffTakeStudent){
        staffTakeStudentDao.updateStaffTakeStudent(staffTakeStudent);
        return "redirect:/staff_update/"+staffTakeStudent.getStaNum();
    }
    //奖励情况编辑
    @PostMapping("/reward_update")
    public String rewardAdd(@ModelAttribute(value = "staffReward") StaffReward staffReward){
        staffRewardDao.updateStaffReward(staffReward);
        return "redirect:/staff_update/"+staffReward.getStaNum();
    }
    //职业培训编辑
    @PostMapping("/train_update")
    public String trainAdd(@ModelAttribute(name = "staffTrain") StaffTrain staffTrain){
        staffTrainDao.updateStaffTrain(staffTrain);
        return "redirect:/staff_update/"+staffTrain.getStaNum();
    }

    //职业资格证书编辑
    @PostMapping("/cert_update")
    public String certAdd(@ModelAttribute(name = "staffCertificate") StaffCertificate staffCertificate){
        staffCertificateDao.updateStaffCertificate(staffCertificate);
        return "redirect:/staff_update/"+staffCertificate.getStaNum();
    }

    //论文发表情况编辑
    @PostMapping("/thesis_update")
    public String thesisAdd(@ModelAttribute(name = "staffThesis") StaffThesis staffThesis){
        staffThesisDao.updateStaffThesis(staffThesis);
        return "redirect:/staff_update/"+staffThesis.getStaNum();
    }

    //教学情况编辑
    @PostMapping("/course_update")
    public String thesisAdd(@ModelAttribute(name = "staffCourse") StaffCourse staffCourse){
        staffCourseDao.updateStaffCourse(staffCourse);
        return "redirect:/staff_update/"+staffCourse.getStaNum();
    }
}
